<script>
export default {
  name: "SelectWarehouseType"
}
</script>
<script setup>
import { apiGetWarehouseEnum } from '@/api/public'

const props = defineProps({
  modelValue: { type: Array, default: () => ([]) },
  valueKey: { type: String, default: 'value' },
  labelKey: { type: String, default: 'label' }
})
const emit = defineEmits(['update:modelValue'])

const optionsList = ref([])

const initOptionsList = async () => {
  const res = await apiGetWarehouseEnum()
  optionsList.value = res.data.wms_attribute
}

onMounted(() => {
  initOptionsList()
})

defineExpose({
  optionsList
})

const warehouseType = computed({
  get: () => {
    return props.modelValue
  },
  set: value => {
    emit('update:modelValue', value)
  }
})
</script>

<template>
  <el-select v-bind="$attrs" filterable clearable collapse-tags v-model="warehouseType">
    <el-option v-for="item in optionsList" :key="item[valueKey]" :label="item[labelKey]" :value="item[valueKey]" />
  </el-select>
</template>

<style scoped lang="scss">
</style>